/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hanze.shoestring.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alex
 */
@Entity
@Table(name = "reistype")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Reistype.findAll", query = "SELECT r FROM Reistype r"),
    @NamedQuery(name = "Reistype.findById", query = "SELECT r FROM Reistype r WHERE r.id = :id"),
    @NamedQuery(name = "Reistype.findByNaam", query = "SELECT r FROM Reistype r WHERE r.naam = :naam")})
public class Reistype implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "naam")
    private String naam;
    @Lob
    @Size(max = 65535)
    @Column(name = "beschrijving")
    private String beschrijving;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reistypeId")
    private List<Reis> reisList;

    public Reistype() {
    }

    public Reistype(Integer id) {
        this.id = id;
    }

    public Reistype(Integer id, String naam) {
        this.id = id;
        this.naam = naam;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNaam() {
        return naam;
    }

    public void setNaam(String naam) {
        this.naam = naam;
    }

    public String getBeschrijving() {
        return beschrijving;
    }

    public void setBeschrijving(String beschrijving) {
        this.beschrijving = beschrijving;
    }

    @XmlTransient
    public List<Reis> getReisList() {
        return reisList;
    }

    public void setReisList(List<Reis> reisList) {
        this.reisList = reisList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reistype)) {
            return false;
        }
        Reistype other = (Reistype) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNaam();
    }
    
}
